package com.digitalchina.lxnsy.viewholder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.ExpertNewVO;
import com.digitalchina.lxnsy.toolkit.FrescoUtil;
import com.facebook.drawee.view.SimpleDraweeView;
import com.hedgehog.ratingbar.RatingBar;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;


/**
 * 专家详情
 */
public class ExpertsDetailHolder extends BaseViewHolder<ExpertNewVO> {

    private SimpleDraweeView ivImage;
    private TextView tvExpertName;
    private TextView title;    //职称
    private TextView tvExpertArea;//涉及领域
    private RatingBar barScore;//评分

    public ExpertsDetailHolder(ViewGroup parent) {
        super(parent, R.layout.item_experts_detail);
        ivImage = $(R.id.item_iv_expert_iv_avatar);
        tvExpertName = $(R.id.item_expert_list_tv_name);
        title = $(R.id.item_expert_list_tv_titles);
        tvExpertArea = $(R.id.item_expert_list_tv_area);
        barScore = $(R.id.item_expert_list_bar_score);
    }

    @Override
    public void setData(ExpertNewVO data) {
        super.setData(data);
        FrescoUtil.showImageSmall(data.getPhoto() != null ? data.getPhoto() : "", ivImage);
        tvExpertName.setText(data.getExpertName() != null ? data.getExpertName() : "");
        if (data.getExpertTitle() != null) {
            title.setText(data.getExpertTitle().getTitle());
        } else
            title.setVisibility(View.GONE);
//        tvExpertArea.setText(data.getExpertClassification() != null ? data.getExpertClassification().getPname() + "  " + data.getExpertClassification().getName() : "");
        if (data.getExpertAreas() != null) {
            String s = "";
            for (int i = 0; i < data.getExpertAreas().size(); i++) {
                s += data.getExpertAreas().get(i).getExpertAreaType().getName() + "-" + data.getExpertAreas().get(i).getExpertAreaDirection().getName() + "\n";
            }
            tvExpertArea.setText(s);
        }
        barScore.setStar((float) data.getScore());
    }
}
